package controlador;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.Sessions;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Menuitem;
import org.zkoss.zul.Window;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zk.ui.select.annotation.Listen;
import java.util.List;

import modelo.hibernate.dao.DaoPublicacion;
import modelo.hibernate.dao.DaoUsuario;
import modelo.hibernate.dao.DaoVehiculo;
import modelo.entidad.Publicacion;

import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.ListModel;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Listbox;




public class ControladorBloquear extends SelectorComposer<Component> /*extends GenericForwardComposer*/{
private static final long serialVersionUID = 1L;
private DaoPublicacion publi = new DaoPublicacion();
private DaoUsuario pubUsu = new DaoUsuario();
private DaoVehiculo pubVeh = new DaoVehiculo();
private Publicacion pub = new Publicacion();
private Listbox list;

private boolean displayEdit = true;

	
	@Wire
	private Menuitem MnuActivar;
	@Wire
	private Menuitem MnuPerfil;
	@Wire
	private Menuitem MnuGestionar;
	@Wire
	private Menuitem MnuCerrar;
	@Wire
	private  Menuitem MnuCostos;
	@Wire
	private Menuitem MnuUsuarios;
	
	public ControladorBloquear(){
		super();
	}
	
	@Listen("onClick = menuitem#MnuActivar")
	public void mostrarMenuActivar(MouseEvent event){
		cerrar();
		Window grid = (Window)Executions.createComponents("ActivarPublicaciones.zul", null, null);
		grid.doModal();
	}
	
	@Listen("onClick = menuitem#MnuPerfil")
	public void mostrarMenuPerfil(MouseEvent event){
		cerrar();
		Window grid = (Window)Executions.createComponents("PerfilAdm.zul", null, null);
		grid.doModal();
	}
	
	@Listen("onClick = menuitem#MnuGestionar")
	public void mostrarMenuGestionar(MouseEvent event){
		cerrar();
		Window grid = (Window)Executions.createComponents("GestionPublicaciones.zul", null, null);
		grid.doModal();
	}
	
	@Listen("onClick = menuitem#MnuCostos")
	public void mostrarMenuCostos(MouseEvent event){
		cerrar();
		Window grid = (Window)Executions.createComponents("GestionCostos.zul", null, null);
		grid.doModal();
	}
	
	@Listen("onClick = menuitem#MnuUsuarios")
	public void mostrarMenuUsuarios(MouseEvent event){
		cerrar();
		Window grid = (Window)Executions.createComponents("GestionUsuarios.zul", null, null);
		grid.doModal();
	}
	
	
	public void cerrar(){
		Window win = (Window)this.getSelf() ;
	    win.detach() ;
	}
	
	@Listen("onClick = menuitem#MnuCerrar")
	public void cerrarSesion(MouseEvent event){
		cerrar();
		Session miSesion = Sessions.getCurrent();
		miSesion.invalidate();
		Executions.sendRedirect("WebPortal.zul");		
	}
	
	public Publicacion getPub(){
		return pub;
	}
	
	public void setPub(Publicacion pub){
		this.pub = pub;
	}
	
	public List<Publicacion> getAllPublicaciones() throws Exception{
		return publi.obtenerTodos();
	}
}

